﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XRoute.Server.Model
{
    class Route : IEnumerable<Node>
    {
        ///////////////////////////////////////////////////////////////////////

        readonly List<Model.Node> _nodes;
        readonly double _totalCost;


        ///////////////////////////////////////////////////////////////////////

        public Route(PathFinding.Path<Node> path)
        {
            _nodes = new List<Node>(path.Reverse());
            _totalCost = path.TotalCost;
        }

        public int Length
        {
            get { return _nodes.Count; }
        }

        public double TotalCost
        {
            get { return _totalCost; }
        }

        public IEnumerator<Node> GetEnumerator()
        {
            return _nodes.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }
    }
}
